$(function () {
    let i = 0;
    $("header").click(function () {
        if (i > 0) {
            $(".post").hide();
            i = 0;
        } else {
            $(".post").show();
            i = 1;
        }
    });
    $(".btn").click(function () {
        let li = $("<li></li>");
        let pic = ['../img/tou01.jpg',
            '../img/tou02.jpg',
            '../img/tou03.jpg',
            '../img/tou04.jpg'
        ]
        let index = Math.floor(Math.random() * 4)
        let img = "<img src=" + pic[index] + ">"
        li.append(img);
        let h1 = $("<h1>" + $(".title").val() + "</h1>");
        li.append(h1);
        let date = new Date();
        let year = date.getFullYear();
        let month = (date.getMonth() + 1 + '').padStart(2, '0')
        let day = (date.getDate() + '').padStart(2, '0')
        let hour = (date.getHours() + '').padStart(2, '0')
        let minute = (date.getMinutes() + '').padStart(2, '0')
        let second = (date.getSeconds() + '').padStart(2, '0')
        let time = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
        let p = $("<p>" + "版块:" + $("select").val() + '&nbsp;&nbsp;&nbsp;&nbsp;' + "<span>发布时间：" + time + "</span></p>");
        li.append(p);
        $(".con ul").prepend(li);
        $(".title,select,textarea").val('')
        $(".post").hide()
    });
});